import {action} from "adajs";
import JoinList from "./../../../controls/lists/join";
import QuestionList from "./../../../controls/lists/question";
import List from "./../../../controls/lists";
import AboardList from "./../../../controls/lists/aboard";
import TabService from "./../../tabservice";
import Page from "../../../lib/page";

class LodgeService extends TabService {
    defaultData() {
        let info = {
            tabs: [
                {
                    "name": "活动报名", active: true, type: List, option: {
                        url: "/api/admin/lgb/noticeinfo/queryPage\n",
                        type: JoinList
                    }
                },
                {
                    "name": "问卷调查", active: false, type: List, option: {
                        url: "/api/lgb/app/lgb/questionnaire/queryPage",
                        type: QuestionList
                    }
                },
                {
                    "name": "出国(境)管理", active: false, type: List, option: {
                        url: "/api/lgb/app/lgb/abroad/queryPage",
                        type: AboardList
                    }
                }
            ],
            btns: []
        };
        this.setTabs(info.tabs);
        if (info.tabs[2].active) {
            info.btns = [{action: "add", icon: ":for-add"}];
        }
        return info;
    }

    @action("setTab")
    setTab(current, name) {
        Page.set(name);
        if (name === '出国(境)管理') {
            current.btns = [{action: "add", icon: ":for-add"}];
        } else {
            current.btns = [];
        }
    }

    onupdate(current, data) {
        Object.assign(current, data);
    }
}

export default LodgeService;